--Message.lua
require 'fairygui.Window'

Message = class(Window)
local prop = property(Message)
prop:accessor("callback", nil)

function Message:__init()
    self:loadLayout("Message", "Main")
end

function Message:initEvent()
    self:addClick("Confirm", function()
        if(self.callback) then
            self.callback(true)
        end
        self:close()
    end)
    self:getChild("Cancel").onClick:Add(function()
        if(self.callback) then
            self.callback(false)
        end
        self:close()
    end)
end

function Message:Show(title, message, cb)
    self.callback = cb
    self:getChild("title").text = title
    self:getChild("message").text = message
end